#pragma once

#include "Screen.h"
#include "Keys.h"
#include "NRF.h"

// ====================================================================================
// Pickup 皮卡遥控类
// ====================================================================================
class Pickup {
public:
  // 构造函数
  Pickup(Screen& screen, Keys& keys, NRF& nrf);

  // 主入口函数
  void main();

private:
  Screen& _screen;
  Keys& _keys;
  NRF& _nrf;

  // 皮卡控制数据结构
  struct PickupKVS {
    // 前端上面两个按键
    bool L_up = HIGH;
    bool R_up = HIGH;

    // int8_t 是有符号char型 -128 到 127
    int8_t LX = 0;
    int8_t LY = 0;
    int8_t RX = 0;
    int8_t RY = 0;

    // 8个功能按键
    bool up = HIGH;
    bool down = HIGH;
    bool left = HIGH;
    bool right = HIGH;
    bool o = HIGH;
    bool x = HIGH;
    bool a = HIGH;
    bool b = HIGH;

    // 4个拨杆开关
    int sw_L1 = HIGH;
    int sw_L2 = HIGH;
    int sw_R1 = HIGH;
    int sw_R2 = HIGH;

    // 电位器旋钮
    int8_t L_knob = 0;
    int8_t R_knob = 0;
  };

  // 初始化NRF通信
  void initNRF();

  // 更新控制数据
  void updateControlData(PickupKVS& kvs);

  // 发送控制数据
  void sendControlData(const PickupKVS& kvs);
};
